package com.elong.businesstravel.modules.member.adapter;

import java.util.List;

import com.elong.businesstravel.R;
import com.elong.businesstravel.entitys.AccountInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 收入明细
 * 
 * @author lenovo
 * 
 */
public class MemberGetBonusAdapter extends BaseAdapter {

	private Context mContext;
	private List<AccountInfo> mAccountInfos;

	public MemberGetBonusAdapter(Context context, List<AccountInfo> accountInfos) {
		mContext = context;
		mAccountInfos = accountInfos;
	}

	@Override
	public int getCount() {
		return mAccountInfos.size();
	}

	@Override
	public Object getItem(int arg0) {
		return mAccountInfos.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {

		if (null == arg1) {
			arg1 = LayoutInflater.from(mContext).inflate(
					R.layout.adapter_member_get_bonus, null);
		}

		AccountInfo accountInfo = mAccountInfos.get(arg0);

		TextView bonusTextView = (TextView) arg1
				.findViewById(R.id.bonusTextView);
		bonusTextView.setText("+" + accountInfo.addscore + "元");
		bonusTextView.setTextColor(mContext.getResources().getColor(
				R.color.money_red));

		ImageView weijihuoImageView = (ImageView) arg1
				.findViewById(R.id.weijihuoImageView);
		if ("-1".equals(accountInfo.status)) {
			// 未激活
			weijihuoImageView.setVisibility(View.VISIBLE);
			bonusTextView.setTextColor(mContext.getResources().getColor(
					R.color.list_gray_text_color));
		} else {
			weijihuoImageView.setVisibility(View.GONE);
			if ("0".equals(accountInfo.status)) {
				// 未激活钱是灰色的
				bonusTextView.setTextColor(mContext.getResources().getColor(
						R.color.list_gray_text_color));
			}
		}

		TextView titleTextView = (TextView) arg1
				.findViewById(R.id.titleTextView);
		if ("".equals(accountInfo.resone)) {
			titleTextView.setText(accountInfo.typeinfo);
		} else {
			titleTextView.setText(accountInfo.resone);
		}
		TextView dateTextView = (TextView) arg1.findViewById(R.id.dateTextView);
		dateTextView.setText(accountInfo.addtime);
		TextView validTextView = (TextView) arg1
				.findViewById(R.id.validTextView);
		validTextView.setText(accountInfo.endtime);

		return arg1;
	}

}
